package offer;

public class MinArray {
    public static void main(String[] args) {
        int[] arr = {4, 5, 6, 7, 0, 1, 3, 3, 3, 3, 3, 3};
        int i = minArray(arr);
        System.out.println(i);
    }

    public static int minArray(int[] numbers) {
        int l = 0;
        int r = numbers.length - 1;
        int mid = 0;
        while (l <= r) {
            if (l == r) {
                return numbers[l];
            }
            if (numbers[mid] < numbers[r]) {
                r = mid;
            } else if (numbers[mid] > numbers[r]) {
                l = mid + 1;
            } else {
                r = r - 1;
            }
            mid = (r + l) / 2;
        }
        return -1;
    }
}
